package com.example.cloudtrade;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;

import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;

public class IndexActivity extends AppCompatActivity {
    private RadioGroup gameTypeRadioGroup;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);

        // 初始化RadioGroup
        gameTypeRadioGroup = findViewById(R.id.game_type_radio_group);

        // 设置RadioGroup的选中状态改变监听器
        gameTypeRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                // 根据选中的RadioButton ID进行相应的处理
                if (checkedId == R.id.radio_button_client_game) {
                    // 端游被选中时的处理逻辑
                } else if (checkedId == R.id.radio_button_mobile_game) {
                    // 手游被选中时的处理逻辑
                }
            }
        });

        // 找到搜索框对应的CardView
        CardView searchCardView = findViewById(R.id.search_card_view); // 这里需要给CardView添加id
        if (searchCardView != null) {
            searchCardView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // 创建Intent并启动SearchActivity
                    Intent intent = new Intent(IndexActivity.this, SearchActivity.class);
                    startActivity(intent);
                }
            });
        }

    }
}